with Ada.Real_Time;		use	Ada.Real_Time;

package body Ball is

	-- corpo dell'oggetto protetto
	protected body Ball is

		-- F: field access
		
		entry StopMoving
			when Owner = 0 and Moving is
		begin
				Moving := False;
	
		end StopMoving;
		
		-- imposta il proprietario del pallone 
		entry Control (ID : in Integer)
			when Owner = 0 is
		begin
			Owner := ID;
		end Control;
		
		-- gestisce il movimento della palla
		entry Movement
			when Moving and Owner = 0 is
		begin
			F.SetBallPosition(Step, Dir);
			Power := Power - 1;
			if (Power = 0) then
				Moving := False;
			end if;
		end Movement;
			
		entry Kick (D : in Integer; S : in Move; Pw : in Integer)
			when Owner /= 0 is
		begin
			Owner := 0;
			Dir := D;
			Step := S;
			Power := Pw;
			Moving := True;
		end Kick;
		
		-- ritorna il possessore della palla
		function GetOwner return Integer is
		begin
			return Owner;
		end GetOwner;
				
	end Ball;

end Ball;
